/*
 * $Id: ShemCheckTask.java,v 1.3 2009/10/07 18:59:27 afaichun Exp $
 * 
 * Copyright (C) 2008 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.processor.dispatcher.tasks;

import java.util.Map;

import org.springframework.util.Assert;

import com.ge.healthcare.autosc.common.ASCUtil;
import com.ge.healthcare.autosc.common.database.dao.IRequestDefn2SweepPropertiesDAO;
import com.ge.healthcare.autosc.common.database.dao.IRequestDefnDAO;
import com.ge.healthcare.autosc.common.database.dao.ISweepPropertiesDAO;
import com.ge.healthcare.autosc.common.database.pojo.ActTask;
import com.ge.healthcare.autosc.common.database.pojo.CfgRequestDefn;
/**
 * Shem check class
 * @author 212042946
 *
 */
public class ShemCheckTask extends ShemJobTask {

	protected static IRequestDefn2SweepPropertiesDAO requestDefn2SweepPropertiesDAO = null;
	protected static IRequestDefnDAO requestDefnDAO = null;
	
	/**
	 * Spring init method.
	 */
	public void init() {
		super.init();
		Assert.notNull(requestDefnDAO,
				"CfgRequestDefnDAO is not defined. Use setRequestDefnDAO to provide one");
		Assert.notNull(
				requestDefn2SweepPropertiesDAO,
				"requestDefn2SweepPropertiesDAO is not defined. Use setRequestDefn2SweepPropertiesDAO() to provide one");
	}
	
	/**
	 * Set RequestDefn2SweepPropertiesDAO
	 * @param requestDefn2SweepPropertiesDAO
	 */
	public void setRequestDefn2SweepPropertiesDAO(
			IRequestDefn2SweepPropertiesDAO requestDefn2SweepPropertiesDAO) {
		ShemCheckTask.requestDefn2SweepPropertiesDAO = requestDefn2SweepPropertiesDAO;
	}
	
	/**
	 * Set RequestDefnDAO
	 * @param requestDefnDAO
	 */
	public void setRequestDefnDAO(IRequestDefnDAO requestDefnDAO) {
		ShemCheckTask.requestDefnDAO = requestDefnDAO;
	}
	
	@Override
	public void executeTask(ActTask actTask) {
		super.executeTask(actTask);
	}

	protected String getServiceId() {
		return "SHEM_CHECK";
	}
	
	/**
	 * Get createdBy property. This is a sweep property
	 * @return createdBy property
	 */
	protected String getCreatedBy() {
		String createdBy = null;
		if(request != null) {
			CfgRequestDefn cfgRequestDefn = requestDefnDAO.getByRequestDefnId(request.getRequestDefnId());
			if(cfgRequestDefn != null) {
				Map<String, String> sweepPropertiesMap = 
					requestDefn2SweepPropertiesDAO.getSweepPropForRequestDefn(cfgRequestDefn.getRequestDefnId());
				if(!ASCUtil.isNullOrEmptyMap(sweepPropertiesMap)) {
					createdBy = sweepPropertiesMap.get(ISweepPropertiesDAO.CREATED_BY);
				}
			}
		}
		return createdBy;
	}
}
